﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;

using Lottery.MediaData.Core;

namespace Lottery.UnitTest.L14 {
    [TestFixture]
    public class Table1 {
        [Test]
        public void Test() {
            var data = new List<DS>();

            // 第1场
            data.Add(new DS(19, 7, 2));

            //2
            data.Add(new DS(12, 14, 16));

            // 第3场
            data.Add(new DS(18, 4, 1));

            // 第4场
            data.Add(new DS(19, 11, 3));

            // 第5场
            data.Add(new DS(6, 10, 18));

            // 第6场
            data.Add(new DS(18, 7, 1));

            // 第7场
            data.Add(new DS(8, 13, 18));

            // 8
            data.Add(new DS(12, 12, 12));

            // 第9场
            data.Add(new DS(19, 4, 13));

            // 10
            data.Add(new DS(11, 19, 15));

            // 第11场
            data.Add(new DS(19, 7, 9));

            // 12
            data.Add(new DS(0, 3, 19));

            // 第13场
            data.Add(new DS(10, 18, 18));
            // 14
            data.Add(new DS(0, 11, 19));

            var result = DSHelper.ProcessAllData(data);

            var r = new[] { 
                new { Key = 19, Value = 7},
                new { Key = 18, Value = 5  },
                new { Key = 16, Value = 1},
                new { Key = 15, Value = 1},
                new { Key = 14, Value = 1},
                new { Key = 13, Value = 2},
                new { Key = 12, Value = 2},
                new { Key = 11, Value = 3},
                new { Key = 10, Value = 2},
                new { Key = 9, Value = 1},
                new { Key = 8, Value = 1},
                new { Key = 7, Value = 3},
                new { Key = 6, Value = 1},
                new { Key = 4, Value = 2},
                new { Key = 3, Value = 2},
                new { Key = 2, Value = 1},
                new { Key = 1, Value = 2},
                new { Key = 0, Value = 2}
            };

            Assert.AreEqual(r.Length, result.Count, "No 0");
            for (int i = 0; i < r.Length; i++) {
                Assert.AreEqual(r[i].Key, result.ElementAt(i).Key, string.Format("No {0}-1", i + 1));
                Assert.AreEqual(r[i].Value, result.ElementAt(i).Value, string.Format("No {0}-2", i + 1));
            }
        }
    }
}
